﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XiaoMan.Model.Models;
using XiaoMan.Factory;
using XiaoMan.DAL;

namespace XiaoMan.BLL
{
    public class UserServices
    {
        private UserDAO dao = SessionFactory.CreatDAO<UserDAO>();
        private SQLHelper sqlhelper = new SQLHelper();
        public bool Add(Sys_Users user)
        {
            dao.Add(user);
            return SessionFactory.Save() > 0;
        }

        public List<Sys_Users> GetListById(int id)
        {
            List<Sys_Users> users = (from u in dao.context.Sys_Users where u.UserID == id select u).ToList();
            return users;
        }

        public List<Sys_Users> GetList()
        {
            string sql = "select * from Sys_Users";
            List<Sys_Users> users=sqlhelper.MakeTablePackage<Sys_Users>(sql);
            return users;
        }
    }
}
